//
//  Condition.hpp
//  Simulation
//
//  Created by Christopher Kemsley on 2/28/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#ifndef Simulation_Condition_hpp
#define Simulation_Condition_hpp

#include "Object.hpp"

NamespaceBegin






// Abstract way for objects to make condition statements
struct	Condition : public Object
{
	virtual bool	isTrue () = 0 ;
} ;






template <typename TargetType,typename ContextType>
struct	ObjectCondition : public Condition
{
	typedef bool	(TargetType::*CallbackMethod)	( ContextType const & context ) const ;
	
	
	// Target & Method cannot be nil
	static Condition*	create		( TargetType const * inTarget , CallbackMethod inMethod , ContextType const & inContext=0 ) ;
	static Condition*	condition	( TargetType const * inTarget , CallbackMethod inMethod , ContextType const & inContext=0 ) ;
	
	
private:
	virtual bool		isTrue () ;
	
	TargetType const *	mTarget ;
	ContextType const	mContext ;
	CallbackMethod		mMethod ;
	
	
	
	// Target & Method cannot be nil
	ObjectCondition		( TargetType const * inTarget , CallbackMethod inMethod , ContextType const & inContext ) ;
} ;






#include "Condition.hxx"
NamespaceEnd
#endif
